import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayOrderVO, PayOrderForm, PayOrderQuery } from '@/api/retail/payOrder/types';

/**
 * 查询支付订单列表
 * @param query
 * @returns {*}
 */

export const listPayOrder = (query?: PayOrderQuery): AxiosPromise<PayOrderVO[]> => {
  return request({
    url: '/retail/payOrder/list',
    method: 'get',
    params: query
  });
};
/**
 * 回调
 * @param id
 * @param validCode
 */
export const notifyPayOrder = (id: string | number | undefined,validCode: string) => {

  return request({
    url: '/retail/payOrder/notify/' + id+'/'+validCode,
    method: 'post',
  });
}
/**
 *  订单冲正
 **/
export const reversePayOrder = (id: string | number | undefined,validCode: string) => {

  return request({
    url: '/retail/payOrder/reverse/' + id+'/'+validCode,
    method: 'post',
  });
}

export const appealPayOrder = (id: string | number | undefined,validCode: string) => {
  return request({
    url: '/retail/payOrder/appeal/' + id+'/'+validCode,
    method: 'post',
  });
}

/**
 * 查询支付订单详细
 * @param id
 */
export const getPayOrder = (id: string | number): AxiosPromise<PayOrderVO> => {
  return request({
    url: '/retail/payOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增支付订单
 * @param data
 */
export const addPayOrder = (data: PayOrderForm) => {
  return request({
    url: '/retail/payOrder',
    method: 'post',
    data: data
  });
};
